public class MyQueue {

  class LLE {
    public Object value;
    public LLE next;
  }

  LLE head;

  public void enq(Object value) {
    LLE newHead = new LLE();
    newHead.value = value;
    newHead.next = head;
    head = newHead;
  }

  public Object deq() {
    // if queue is empty
    if (head == null)
      return null;
    // 
    LLE tail = head;
    // if we have only one element
    if (head.next == null) {
      head = null;
      return tail;
    }
    // if there are more than element in the queue
    while (tail.next != null) {
      tail = tail.next; 
    }

    return tail.value;
  }

}
